/**
 * 
 */
package com.thinkgsp.jxc.model;

import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Date;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * 产品批号表
 * @author evan
 *
 */
public class ProductBatchNo extends BaseModel implements Serializable {

	/**
	 * 非批号管理的批号值
	 */
	public final static String NON_BATCH_MGR_VALUE = "-";

	private static final long serialVersionUID = 3276316658160591267L;

	private Long id;
	private Integer productId;
	private String batchNo;
	private Date manufDate;
	private Date expDate;
	private Date lastIncomeDate;
	private BigDecimal lastIncomePrice;
	private Integer lastIncomeSupper;
	
	/**
	 * 批号表ID
	 * @return
	 */
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * 产品ID
	 * @return
	 */
	public Integer getProductId() {
		return productId;
	}

	public void setProductId(Integer productId) {
		this.productId = productId;
	}

	/**
	 * 生产批号
	 * @return
	 */
	public String getBatchNo() {
		return batchNo;
	}

	public void setBatchNo(String batchNo) {
		this.batchNo = batchNo;
	}

	/**
	 * 生产企业
	 * @return
	 */
	public Date getManufDate() {
		return manufDate;
	}

	public void setManufDate(Date manufDate) {
		this.manufDate = manufDate;
	}

	/**
	 * 有效期
	 * @return
	 */
	public Date getExpDate() {
		return expDate;
	}

	public void setExpDate(Date expDate) {
		this.expDate = expDate;
	}

	/**
	 * 最后到货日期
	 * @return
	 */
	public Date getLastIncomeDate() {
		return lastIncomeDate;
	}

	public void setLastIncomeDate(Date lastIncomeDate) {
		this.lastIncomeDate = lastIncomeDate;
	}

	/**
	 * 最后进价
	 * @return
	 */
	public BigDecimal getLastIncomePrice() {
		return lastIncomePrice;
	}

	public void setLastIncomePrice(BigDecimal lastIncomePrice) {
		this.lastIncomePrice = lastIncomePrice;
	}

	/**
	 * 最近供货商
	 * @return
	 */
	public Integer getLastIncomeSupper() {
		return lastIncomeSupper;
	}

	public void setLastIncomeSupper(Integer lastIncomeSupper) {
		this.lastIncomeSupper = lastIncomeSupper;
	}
	
	/**
	 * 是否空批号
	 * @return
	 */
	public boolean isNonBatchNo() {
		return NON_BATCH_MGR_VALUE.equals(batchNo);
	}

	/* (non-Javadoc)
	 * @see com.thinkgsp.jxc.model.BaseModel#toString()
	 */
	@Override
	public String toString() {
		ToStringBuilder sb = new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE);
		sb.append("id",this.id)
		  .append("productId",this.productId)
		  .append("batchNo",this.batchNo)
		  .append("manufDate",this.manufDate)
		  .append("expDate",this.expDate);
		
		return sb.toString();
	}

	/* (non-Javadoc)
	 * @see com.thinkgsp.jxc.model.BaseModel#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object o) {
		if(this == o) {
			return true;
		}
		if(!(o instanceof ProductBatchNo)) {
			return false;
		}
		final ProductBatchNo pbn = (ProductBatchNo)o;
		if(id != null) {
			return id.equals(pbn.getId());
		} else {
			return pbn.getId() == null;
		}
	}

	/* (non-Javadoc)
	 * @see com.thinkgsp.jxc.model.BaseModel#hashCode()
	 */
	@Override
	public int hashCode() {
		return (this.id != null ? this.id.hashCode() : 0);
	}

}
